package com.itggm.mapper;

import com.itggm.pojo.Emp;

import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {
    //获取总记录数
   /* @Select("select count(*) from emp")
    public Long count();
    //获取当前页的结果列表
    @Select("select * from emp limit #{start}, #{pageSize}")
    public List<Emp> list(@Param("start") Integer start, @Param("pageSize") Integer pageSize);*/

    //使用pageHelper插件实现分页查询
    //获取当前页的结果列表
    List<Emp> list (@Param("name") String name,@Param("gender") Short gender,
                    @Param("begin") LocalDate begin, @Param("end") LocalDate end);
    //新增员工
    @Insert("insert into emp (username, name, gender, image, job, entrydate, dept_id, create_time, update_time) " +
            "values (#{username}, #{name}, #{gender}, #{image}, #{job}, #{entrydate}, #{deptId}, #{createTime}, #{updateTime});")
    void insert(Emp emp);
    //批量删除员工
    void delete(@Param("ids") List<Integer> ids);
    @Select("select id, username, password, name, gender, image, job, " +
            "entrydate, dept_id, create_time, update_time " +
            "from emp " + "where id = #{id}")
    Emp getByID(@Param("id") Integer id);
    //修改员工信息
    public void update(Emp emp);
    //登录验证
    @Select("select * from emp where username = #{username} and password = #{password}" )
    Emp getByUsernameAndPassword(Emp emp);

}
